﻿using System;
using System.Web.Mvc;

namespace DotNetBurner.Web
{
    [AttributeUsage (AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
    public class CompressFilter : ActionFilterAttribute
    {
        public override void OnResultExecuted (ResultExecutedContext context)
        {
            if ((context.Exception == null) || ((context.Exception != null) && context.ExceptionHandled))
            {
                context.HttpContext.CompressResponse ();
            }

            base.OnResultExecuted (context);
        }
    }
}